<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>7-async函数处理多个异步请求</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

    <style></style>
  </head>
  <body>
    <div id="app"></div>
    <script>
      // 1:设置请求根路径
      axios.defaults.baseURL = 'http://www.localhost:3000';
      // 2：封装函数，发送请求，将请求到的结果return
      async function getData() {
        var info = await axios.get('async1');
        var res = await axios.get('async2?info=' + info.data);
        return res.data;
      }
      // 3:调用函数,将函数的结果输出
      getData().then(function (data) {
        console.log(data);
      });
    </script>
  </body>
</html>
